About HTML Tidy

Introduction to TIDY

When editing HTML it's easy to make mistakes. Wouldn't it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely layed out markup? Well now there is! Dave Raggett's HTML TIDY is a free utility for doing just that. It also works great on the atrociously hard to read markup generated by specialized HTML editors and conversion tools, and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.

Tidy is able to fix up a wide range of problems and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup. Tidy won't generate a cleaned up version when there are problems that it can't be sure of how to handle. These are logged as "errors" rather than "warnings".

Examples of TIDY at work

Tidy corrects the markup in a way that matches where possible the observed rendering in popular browsers from Netscape and Microsoft. Here are just a few examples of how TIDY perfects your HTML for you:

  • Missing or mismatched end tags are detected and corrected
       <h1>heading
   <h2>subheading</h3>

    is mapped to

       <h1>heading</h1>
   <h2>subheading</h2>
  • End tags in the wrong order are corrected:
       <p>here is a para <b>bold <i>bold italic</b> bold?</i> normal?

    is mapped to

       <p>here is a para <b>bold <i>bold italic</i> bold?</b> normal?
  • Fixes problems with heading emphasis
       <h1><i>italic heading</h1>
   <p>new paragraph

    In Netscape and Internet Explorer this causes everything following the heading to be in the heading font size, not the desired effect at all!

    Tidy maps the example to

       <h1><i>italic heading</i></h1>
   <p>new paragraph
  • Recovers from mixed up tags
       <i><h1>heading</h1></i>
   <p>new paragraph <b>bold text
   <p>some more bold text

    Tidy maps this to

       <h1><i>heading</i></h1>
   <p>new paragraph <b>bold text</b>
   <p><b>some more bold text</b>
  • Getting the <hr> in the right place:
       <h1><hr>heading</h1>
   <h2>sub<hr>heading</h2>

    Tidy maps this to

       <hr>
   <h1>heading</h1>
   <h2>sub</h2>
   <hr>
   <h2>heading</h2>
  • Adding the missing "/" in end tags for anchors:
       <a href="#refs">References<a>

    Tidy maps this to

       <a href="#refs">References</a>
  • Perfecting lists by putting in tags missed out:
       <body>
   <li>1st list item
   <li>2nd list item

    is mapped to

       <body>
   <ul>
   <li>1st list item</li>
   <li>2nd list item</li>
   </ul>
  • Missing quotes around attribute values are added

    Tidy inserts quote marks around all attribute values for you. It can also detect when you have forgotten the closing quote mark, although this is something you will have to fix yourself.

  • Unknown/Proprietary attributes are reported

    Tidy has a comprehensive knowledge of the attributes defined in the HTML 4.0 recommendation from W3C. This often allows you to spot where you have mistyped an attribute or value.

  • Proprietary elements are recognized and reported as such.

    Tidy will even work out which version of HTML you are using and insert the appropriate DOCTYPE element, as per the W3C recommendations.

  • Tags lacking a terminating '>' are spotted

    This is something you then have to fix yourself as Tidy is unsure of where the > should be inserted.

Layout style

You can choose which style you want Tidy to use when it generates the cleaned up markup: for instance whether you like elements to indent their contents or not. Several people have asked if Tidy could preserve the original layout. I am sorry to say that this would be very hard to support due to the way Tidy is implemented. Tidy starts by building a clean parse tree from the source file. The parse tree doesn't contain any information about the original layout. Tidy then pretty prints the parse tree using the current layout options. Trying to preserve the original layout would interact badly with the repair operations needed to build a clean parse tree and considerably complicate the code.

Some browsers can screw up the right alignment of text depending on how you layout headings. As an example, consider:

<h1 align="right">
  Heading
</h1>

<h1 align="right">Heading</h1>

Both of these should be rendered the same. Sadly a common browser bug fails to trim trailing whitespace and misaligns the first heading. HTML Tidy will protect you from this bug, except when you set the indent option to "yes".

Setting the indent option to yes can also cause problems with table layout for some browsers:

<td><img src="foo.gif"></td>
<td><img src="foo.gif"></td>

will look slightly different from:

<td>
  <img src="foo.gif">
</td>
<td>
  <img src="foo.gif">
</td>

You can avoid such quirks by using indent: no or indent: auto in the config file.

Internationalization issues

Tidy offers you a choice of character encodings: US ASCII, ISO Latin-1, UTF-8 and the ISO 2022 family of 7 bit encodings. The full set of HTML 4.0 entities are defined. Cleaned up output uses HTML entity names for characters when appropriate. Otherwise characters outside the normal range are output as numeric character entities. Tidy defaults to assuming you want the output to be in US ASCII. Tidy doesn't yet recognize the use of the HTML meta element for specifying the character encoding.

Accessibility

Tidy offers advice on accessibility problems for people using non-graphical browsers. The most common thing you will see is the suggestion you add a summary attribute to table elements. The idea is to provide a summary of the table's role and structure suitable for use with aural browsers.

Cleaning up presentational markup

Many tools generate HTML with an excess of FONT, NOBR and CENTER tags. Tidy's -clean option will replace them by style properties and rules using CSS. This makes the markup easier to read and maintain as well as reducing the file size! Tidy is expected to get smarter at this in the future.

Some pages rely on the presentation effects of isolated <p> or </p> tags.Tidy deletes empty paragraph and heading elements etc. The use of empty paragraph elements is not recommended for adding vertical whitespace. Instead use style sheets, or the <br> element. Tidy won't discard paragraphs only containing a nonbreaking space &nbsp;

Teaching Tidy about new tags!

You can teach Tidy about new tags by declaring them in the configuration file, the syntax is:

  new-inline-tags: tag1, tag2, tag3
  new-empty-tags: tag1, tag2, tag3
  new-blocklevel-tags: tag1, tag2, tag3
  new-pre-tags: tag1, tag2, tag3

The same tag can be defined as empty and as inline or as empty and as block.

These declarations can be combined to define an a new empty inline or empty block element, but you are not advised to declare tags as being both inline and block!

Note that the new tags can only appear where Tidy expects inline or block-level tags respectively. This means you can't (yet) place new tags within the document head or other contexts with restricted content models. So far the most popular use of this feature is to allow Tidy to be applied to Cold Fusion files.

I am working on ways to make it easy to customize the permitted document syntax using assertion grammars, and hope to apply this to a much smarter version of Tidy for release later this year or early next year.

Limited support for ASP, JSTE and PHP

Tidy is somewhat aware of the preprocessing language called ASP which uses a pseudo element syntax <% ... %> to include preprocessor directives. ASP is normally interpreted by the web server before delivery to the browser. JSTE shares the same syntax, but sometimes also uses <# ... #>. Tidy can also cope with another such language called PHP, which uses the syntax <?php ... ?>

Tidy will cope with ASP, JSTE and PHP pseudo elements within element content and as replacements for attributes, for example:

  <option <% if rsSchool.Fields("ID").Value
    = session("sessSchoolID")
    then Response.Write("selected") %>
    value='<%=rsSchool.Fields("ID").Value%>'>
    <%=rsSchool.Fields("Name").Value%>
    (<%=rsSchool.Fields("ID").Value%>)
  </option>

Note that Tidy doesn't understand the scripting language used within pseudo elements and attributes, and can easily get confused. Tidy may report missing attributes when these are hidden within preprocessor code. Tidy can also get things wrong if the code includes quote marks, e.g. if the example above is changed to:

    value="<%=rsSchool.Fields("ID").Value%>"

Tidy will now see the quote mark preceding ID as ending the attribute value, and proceed to complain about what follows. Note you can choose whether to allow line wrapping on spaces within pseudo elements or not using the wrap-asp option. If you used ASP, JSTE or PHP to create a start tag, but placed the end tag explicitly in the markup, Tidy won't be able to match them up, and will delete the end tag for you. So in this case you are advise to make the start tag explicit and to use ASP, JSTE or PHP for just the attributes, e.g.

   <a href="<%=random.site()%>">do you feel lucky?</a>

Tidy allows you to control whether line wrapping is enabled for ASP, JSTE and PHP instructions, see the wrap-asp, wrap-jste and wrap-php config options, respectively.

I regret that Tidy does not support Tango preprocessing instructions which look like:

<@if variable_1='a'>
    do something
<@else>
    do nothing
</@if>

<@include <@cgi><@appfilepath>includes/message.html>

Tidy supports another preprocessing syntax called "Tango", but only for attribute values. Adding support for pseudo elements written in Tango looks as if it would be quite tough, so I would like to gauge the level of interest before committing to this work.

Limited support for XML

XML processors compliant with W3C's XML 1.0 recommendation are very picky about which files they will accept. Tidy can help you to fix errors that cause your XML files to be rejected. Tidy doesn't yet recognize all XML features though, e.g. it doesn't understand CDATA sections or DTD subsets.


HTML Tidy and HTMLPad 2002 integration

HTML Tidy and HTMLPad 2002

HTML Tidy itself is a command line utility with no user interface. HTMLPad provides graphical user interface to running and configuring HTML Tidy so you do not need to know about command line parameters or configuration files. You can run and configure HTML Tidy right from HTMLPad.

Running HTML Tidy

To run HTML Tidy, from the Tools menu choose HTML Tidy - Run Tidy Task. You can select from a list of available tasks.You can also create and configure your own tasks.

Configuring HTML Tidy

To create, manage and configure HTML Tidy, from the Tools menu choose HTML Tidy - Configure Tidy Tasks.


HTML Tidy Configuration Options Quick Reference

HTML Tidy Configuration Options

HTML, XHTML, XML
Diagnostics
Pretty Print
Character Encoding
Miscellaneous

HTML, XHTML, XML Options |  | Top
Option | Type | Default
add-xml-decl | Boolean | no
add-xml-pi | Boolean | no
add-xml-space | Boolean | no
alt-text | String |
assume-xml-procins | Boolean | no
bare | Boolean | no
break-before-br | Boolean | no
clean | Boolean | no
doctype | DocType | auto
drop-empty-paras | Boolean | yes
drop-font-tags | Boolean | no
drop-proprietary-attributes | Boolean | no
enclose-block-text | Boolean | no
enclose-text | Boolean | no
escape-cdata | Boolean | no
fix-bad-comments | Boolean | yes
fix-uri | Boolean | yes
hide-comments | Boolean | no
hide-endtags | Boolean | no
indent-cdata | Boolean | no
input-xml | Boolean | no
join-classes | Boolean | no
join-styles | Boolean | yes
logical-emphasis | Boolean | no
lower-literals | Boolean | yes
ncr | Boolean | yes
new-blocklevel-tags | Tag names |
new-empty-tags | Tag names |
new-inline-tags | Tag names |
new-pre-tags | Tag names |
numeric-entities | Boolean | no
output-xhtml | Boolean | no
output-xml | Boolean | no
quote-ampersand | Boolean | yes
quote-marks | Boolean | no
quote-nbsp | Boolean | yes
repeated-attributes | - | keep-last
replace-color | Boolean | no
show-body-only | Boolean | no
slide-style | Name |
split | Boolean | no
uppercase-attributes | Boolean | no
uppercase-tags | Boolean | no
word-2000 | Boolean | no
Diagnostics Options |  | Top
Option | Type | Default
error-file | String |
force-output | Boolean | no
gnu-emacs | Boolean | no
quiet | Boolean | no
show-errors | Integer | 6
show-warnings | Boolean | yes
tidy-mark | Boolean | yes
Pretty Print Options |  | Top
Option | Type | Default
indent | AutoBool | no
indent-attributes | Boolean | no
indent-spaces | Integer | 2
literal-attributes | Boolean | no
markup | Boolean | yes
tab-size | Integer | 4
wrap | Integer | 68
wrap-asp | Boolean | yes
wrap-attributes | Boolean | no
wrap-jste | Boolean | yes
wrap-php | Boolean | yes
wrap-script-literals | Boolean | no
wrap-sections | Boolean | yes
Character Encoding Options |  | Top
Option | Type | Default
ascii-chars | Boolean | yes
char-encoding | Encoding | ascii
input-encoding | Encoding | latin1
language | Language |
output-bom | AutoBool | auto
output-encoding | Encoding | ascii
raw | Boolean | no
Miscellaneous Options |  | Top
Option | Type | Default
fix-backslash | Boolean | yes
keep-time | Boolean | yes
write-back | Boolean | no
HTML, XHTML, XML Options Reference
add-xml-decl | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should add the XML declaration when outputting XML or XHTML. Note that if the input already includes an <?xml ... ?> declaration then this option will be ignored.
add-xml-pi | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option is the same as the add-xml-decl option.
add-xml-space | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should add xml:space="preserve" to elements such as <PRE>, <STYLE> and <SCRIPT> when generating XML. This is needed if the whitespace in such elements is to be parsed appropriately without having access to the DTD.
alt-text | Top
Type: String Default: -none- |
This option specifies the default "alt=" text Tidy uses for <IMG> attributes. This feature is dangerous as it suppresses further accessibility warnings. You are responsible for making your documents accessible to people who can not see the images!
assume-xml-procins | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should change the parsing of processing instructions to require ?> as the terminator rather than >. This option is automatically set if the input is in XML.
bare | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should strip Microsoft specific HTML from Word 2000 documents, and output spaces rather than non-breaking spaces where they exist in the input.
break-before-br | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output a line break before each <BR> element.
clean | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should strip out surplus presentational tags and attributes replacing them by style rules and structural markup as appropriate. It works well on the HTML saved by Microsoft Office products.
doctype | Top
Type: DocType Default: auto Example: auto, omit, strict, loose, transitional, user specified fpi (string) |
This option specifies the DOCTYPE declaration generated by Tidy. If set to "omit" the output won't contain a DOCTYPE declaration. If set to "auto" (the default) Tidy will use an educated guess based upon the contents of the document. If set to "strict", Tidy will set the DOCTYPE to the strict DTD. If set to "loose", the DOCTYPE is set to the loose (transitional) DTD. Alternatively, you can supply a string for the formal public identifier (FPI). For example: doctype: "-//ACME//DTD HTML 3.14159//EN" If you specify the FPI for an XHTML document, Tidy will set the system identifier to the empty string. Tidy leaves the DOCTYPE for generic XML documents unchanged.
drop-empty-paras | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should discard empty paragraphs. If set to no, empty paragraphs are replaced by a pair of <BR> elements as HTML4 precludes empty paragraphs.
drop-font-tags | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should discard <FONT> and <CENTER> tags rather than creating the corresponding style rules, but only if the clean option is also set to yes.
drop-proprietary-attributes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should strip out proprietary attributes, such as MS data binding attributes.
enclose-block-text | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should insert a <P> element to enclose any text it finds in any element that allows mixed content for HTML transitional but not HTML strict.
enclose-text | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should enclose any text it finds in the body element within a <P> element. This is useful when you want to take existing HTML and use it with a style sheet.
escape-cdata | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should convert <![CDATA[]]> sections to normal text.
fix-bad-comments | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should replace unexpected hyphens with "=" characters when it comes across adjacent hyphens. The default is yes. This option is provided for users of Cold Fusion which uses the comment syntax: <!--- --->
fix-uri | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should check attribute values that carry URIsfor illegal characters and if such are found, escape them as HTML 4 recommends.
hide-comments | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should print out comments.
hide-endtags | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should omit optional end-tags when generating the pretty printed markup. This option is ignored if you are outputting to XML.
indent-cdata | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should indent <![CDATA[]]> sections.
input-xml | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should use the XML parser rather than the error correcting HTML parser.
join-classes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 | join-styles repeated-attributes
This option specifies if Tidy should combine class names to generate a single new class name, if multiple class assignments are detected on an element.
join-styles | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 | join-classes repeated-attributes
This option specifies if Tidy should combine styles to generate a single new style, if multiple style values are detected on an element.
logical-emphasis | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should replace any occurrence of <I> by <EM> and any occurrence of <B> by <STRONG>. In both cases, the attributes are preserved unchanged. This option can be set independently of the clean and drop-font-tags options.
lower-literals | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should convert the value of an attribute that takes a list of predefined values to lower case. This is required for XHTML documents.
ncr | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should allow numeric character references.
new-blocklevel-tags | Top
Type: Tag names Default: -none- Example: tagX, tagY, ... |
This option specifies new block-level tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can't change the content model for elements such as <TABLE>, <UL>, <OL> and <DL>.
new-empty-tags | Top
Type: Tag names Default: -none- Example: tagX, tagY, ... | new-blocklevel-tags new-inline-tags
This option specifies new empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Remember to also declare empty tags as either inline or blocklevel.
new-inline-tags | Top
Type: Tag names Default: -none- Example: tagX, tagY, ... |
This option specifies new non-empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
new-pre-tags | Top
Type: Tag names Default: -none- Example: tagX, tagY, ... |
This option specifies new tags that are to be processed in exactly the same way as HTML's <PRE> element. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can not as yet add new CDATA elements (similar to <SCRIPT>).
numeric-entities | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output entities other than the built-in HTML entities (&amp;, &lt;, &gt; and &quot;) in the numeric rather than the named entity form.
output-xhtml | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should generate pretty printed output, writing it as extensible HTML. This option causes Tidy to set the DOCTYPE and default namespace as appropriate to XHTML. If a DOCTYPE or namespace is given they will checked for consistency with the content of the document. In the case of an inconsistency, the corrected values will appear in the output. For XHTML, entities can be written as named or numeric entities according to the setting of the "numeric-entities" option. The original case of tags and attributes will be preserved, regardless of other options.
output-xml | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should pretty print output, writing it as well-formed XML. Any entities not defined in XML 1.0 will be written as numeric entities to allow them to be parsed by a XML parser. The original case of tags and attributes will be preserved, regardless of other options.
quote-ampersand | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output unadorned & characters as &amp;.
quote-marks | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output " characters as &quot; as is preferred by some editing environments. The apostrophe character ' is written out as &#39; since many web browsers don't yet support &apos;.
quote-nbsp | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output non-breaking space characters as entities, rather than as the Unicode character value 160 (decimal).
repeated-attributes | Top
Type: - Default: keep-last Example: keep-first, keep-last | join-classes join-styles
This option specifies if Tidy should keep the first or last attribute, if an attribute is repeated, e.g. has two align attributes.
replace-color | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should replace numeric values in color attributes by HTML/XHTML color names where defined, e.g. replace "#ffffff" with "white".
show-body-only | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should print only the contents of the body tag as an HTML fragment. Useful for incorporating existing whole pages as a portion of another page.
slide-style | Top
Type: Name Default: -none- | split
Currently not used.
split | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should create a sequence of slides from the input, splitting the markup prior to each successive <H2>. The slides are written to "slide001.html", "slide002.html" etc.
uppercase-attributes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output attribute names in upper case. The default is no, which results in lower case attribute names, except for XML input, where the original case is preserved.
uppercase-tags | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output tag names in upper case. The default is no, which results in lower case tag names, except for XML input, where the original case is preserved.
word-2000 | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages". Doesn't handle embedded images or VML.
Diagnostics Options Reference
error-file | Top
Type: String Default: -none- |
This option specifies the error file Tidy uses for errors and warnings. Normally errors and warnings are output to "stderr".
force-output | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should produce output even if errors are encountered. Use this option with care - if Tidy reports an error, this means Tidy was not able to, or is not sure how to, fix the error, so the resulting output may not reflect your intention.
gnu-emacs | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should change the format for reporting errors and warnings to a format that is more easily parsed by GNU Emacs.
quiet | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should output the summary of the numbers of errors and warnings, or the welcome or informational messages.
show-errors | Top
Type: Integer Default: 6 Example: 0, 1, 2, ... |
This option specifies the number Tidy uses to determine if further errors should be shown. If set to 0, then no errors are shown.
show-warnings | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should suppress warnings. This can be useful when a few errors are hidden in a flurry of warnings.
tidy-mark | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should add a meta element to the document head to indicate that the document has been tidied. Tidy won't add a meta element if one is already present.
Pretty Print Options Reference
indent | Top
Type: AutoBool Default: no Example: auto, y/n, yes/no, t/f, true/false, 1/0 | indent-spaces
This option specifies if Tidy should indent block-level tags. If set to "auto", this option causes Tidy to decide whether or not to indent the content of tags such as TITLE, H1-H6, LI, TD, TD, or P depending on whether or not the content includes a block-level element. You are advised to avoid setting indent to yes as this can expose layout bugs in some browsers.
indent-attributes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should begin each attribute on a new line.
indent-spaces | Top
Type: Integer Default: 2 Example: 0, 1, 2, ... | indent
This option specifies the number of spaces Tidy uses to indent content, when indentation is enabled.
literal-attributes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should ensure that whitespace characters within attribute values are passed through unchanged.
markup | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should generate a pretty printed version of the markup. Note that Tidy won't generate a pretty printed version if it finds significant errors (see force-output).
tab-size | Top
Type: Integer Default: 4 Example: 0, 1, 2, ... |
This option specifies the number of columns that Tidy uses between successive tab stops. It is used to map tabs to spaces when reading the input. Tidy never outputs tabs.
wrap | Top
Type: Integer Default: 68 Example: 0 (no wrapping), 1, 2, ... |
This option specifies the right margin Tidy uses for line wrapping. Tidy tries to wrap lines so that they do not exceed this length. Set wrap to zero if you want to disable line wrapping.
wrap-asp | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should line wrap text contained within ASP pseudo elements, which look like: <% ... %>.
wrap-attributes | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 | wrap-script-literals
This option specifies if Tidy should line wrap attribute values, for easier editing. This option can be set independently of wrap-script-literals.
wrap-jste | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should line wrap text contained within JSTE pseudo elements, which look like: <# ... #>.
wrap-php | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should line wrap text contained within PHP pseudo elements, which look like: <?php ... ?>.
wrap-script-literals | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 | wrap-attributes
This option specifies if Tidy should line wrap string literals that appear in script attributes. Tidy wraps long script string literals by inserting a backslash character before the line break.
wrap-sections | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should line wrap text contained within <![ ... ]> section tags.
Character Encoding Options Reference
ascii-chars | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 | char-encoding
Can be used to modify behavior of -c (--clean yes) option. Defaults to "yes" when using -c. Set to "no" to prevent converting >emdash;, &rdquo;, and other named character entities to their ascii equivalents.
char-encoding | Top
Type: Encoding Default: ascii Example: ascii, latin1, raw, utf8, iso2022, mac, win1252 | input-encoding output-encoding
This option specifies the character encoding Tidy uses for both the input and output. For ascii, Tidy will accept Latin-1 (ISO-8859-1) character values, but will use entities for all characters whose value > 127. For raw, Tidy will output values above 127 without translating them into entities. For latin1, characters above 255 will be written as entities. For utf8, Tidy assumes that both input and output is encoded as UTF-8. You can use iso2022 for files encoded using the ISO-2022 family of encodings e.g. ISO-2022-JP. For mac and win1252, Tidy will accept vendor specific character values, but will use entities for all characters whose value > 127.
input-encoding | Top
Type: Encoding Default: latin1 Example: ascii, latin1, raw, utf8, iso2022, mac, win1252 | char-encoding
This option specifies the character encoding Tidy uses for the input. See char-encoding for more info.
language | Top
Type: Language Default: -none- Example: en |
Currently not used, but this option specifies the language Tidy uses.
output-bom | Top
Type: AutoBool Default: auto Example: auto, y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should write a Unicode Byte Order Mark character (BOM; also known as Zero Width No-Break Space; has value of U+FEFF) to the beginning of the output; only for UTF-8 and UTF-16 output encodings. If set to "auto", this option causes Tidy to write a BOM to the output only if a BOM was present at the beginning of the input. A BOM is always written for XML/XHTML output using UTF-16 output encodings.
output-encoding | Top
Type: Encoding Default: ascii Example: ascii, latin1, raw, utf8, iso2022, mac, win1252 | char-encoding
This option specifies the character encoding Tidy uses for the output. See char-encoding for more info. May only be different from input-encoding for Latin encodings (ascii, latin1, mac, win1252).
raw | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 | char-encoding
Currently not used, but this option would be the same as the char-encoding: raw option.
Miscellaneous Options Reference
fix-backslash | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should replace backslash characters "\" in URLs by forward slashes "/".
keep-time | Top
Type: Boolean Default: yes Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should alter the last modified time for files it writes back to. The default is no, which allows you to tidy files without affecting which ones will be uploaded to a Web server when using a tool such as 'SiteCopy'. Note that this feature may not work on some platforms.
write-back | Top
Type: Boolean Default: no Example: y/n, yes/no, t/f, true/false, 1/0 |
This option specifies if Tidy should write back the tidied markup to the same file it read from. You are advised to keep copies of important files before tidying them, as on rare occasions the result may not be what you expect.